//
//  WTFDYHDVC.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/18.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "WTFDYHDVC.h"
#import "SYNoLabel.h"


@interface WTFDYHDVC ()

@property (strong, nonatomic) SYNoLabel *noLab;
@property (strong, nonatomic) UIView *fgxView;
@property (copy, nonatomic) NSString *banjiId;
@property (copy, nonatomic) NSString *keyStr;

@end

@implementation WTFDYHDVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initSubView];
}
- (void)initSubView{
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:self.leftTableList.view];
    [_leftTableList.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.right.equalTo(self.view.mas_centerX).offset(-50);
        make.top.equalTo(@0);
        make.bottom.equalTo(@0);
    }];
    
    _fgxView = [[UIView alloc]init];
    _fgxView.hidden = YES;
    _fgxView.backgroundColor = LINCOLOR;
    [self.view addSubview:_fgxView];
    [_fgxView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftTableList.view.mas_right);
        make.width.equalTo(@1);
        make.top.equalTo(self.leftTableList.view.mas_top);
        make.bottom.equalTo(@0);
    }];
    
    [self.view addSubview:self.rightList.view];
    [_rightList.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.fgxView.mas_right);
        make.top.equalTo(self.leftTableList.view.mas_top);
        make.right.equalTo(@0);
        make.bottom.equalTo(@0);
    }];
    
    _noLab = [[SYNoLabel alloc] initWithNameStr:@"" contView:self.view];
//    _noLab.hidden = YES;
    __weak typeof(self) weakSelf = self;
    self.leftTableList.wtBlock = ^(NSInteger index) {
        [weakSelf requestDataList];
    };
//
    //点击了cell或者搜索
    
    self.leftTableList.block = ^(SYWenTiFuDaoModel * _Nonnull model, NSString * _Nonnull wordKey) {
        [weakSelf.rightList requestData:model];
    };
}
- (void)requestDataBanjiId:(NSString *)banji keyStr:(NSString *)keyStr {
    self.keyStr = keyStr;
    _banjiId = banji;
    [self requestDataList];
}
- (void)requestDataList {
    self.leftTableList.view.hidden = NO;
    self.rightList.view.hidden = NO;
    self.fgxView.hidden = NO;
    __weak typeof(self) weakSelf = self;
    [MBProgressHUD mj_showMessage:nil toView:self.view];
    if (_banjiId.length == 0) {
        _banjiId = @"0";
    }
    [SYRequestAPI fd_requestTutorQuestionTutorServiceIsAnswer:@"1" keyword:self.keyStr classId:_banjiId pageIndex:0 pageSize:1000 success:^(NSMutableArray *listArr) {
        [MBProgressHUD mj_hideHUDForView:self.view];
        [weakSelf.leftTableList chuanrushujuDataListArr:listArr];
        if (listArr.count > 0) {
            [weakSelf.rightList requestData:listArr.firstObject];
        } else {
            [weakSelf.rightList requestNotData];
        }
    } fail:^(NSError *error) {
        [MBProgressHUD mj_hideHUDForView:self.view];
        [weakSelf.leftTableList chuanrushujuDataListArr:[NSMutableArray array]];
        [weakSelf.rightList requestNotData];
        
    }];
}


- (WTFDYHDLeftList *)leftTableList{
    if (!_leftTableList) {
        WTFDYHDLeftList *view = [[WTFDYHDLeftList alloc]init];
        _leftTableList = view;
    }
    return _leftTableList;
}
- (WTFDYHDRightList *)rightList{
    if (!_rightList) {
        WTFDYHDRightList *view = [[WTFDYHDRightList alloc]init];
        _rightList = view;
    }
    return _rightList;
}

@end
